﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PracticLesson13._12._14
{
    public class Robot
    {
        public int _x;
        public int _y;
        public int _lastPrintedX;
        public int _lastPrintedY;
        public bool _hasBeenPrinted;
        public int[,] _stepsHasBeen;
        public ConsoleColor _color;
        
        public void MoveLeft(int interval)
        {
            _x -= interval;

            _x = Math.Max(_x, 0);
        }
        public void MoveRight(int interval)
        {
            _x += interval;

            _x = Math.Min(_x, 69/*Console.BufferWidth - 1*/);
        }
        public void MoveTop(int interval)
        {
            _y -= interval;

            _y = Math.Max(_y, 0);
        }
        public void MoveBottom(int interval)
        {
            _y += interval;

            _y = Math.Min(_y, 24/*Console.BufferHeight - 1*/);
        }
        public void Print ()
        {
            
            if (_hasBeenPrinted)
            {
                //clear previous position
                Console.SetCursorPosition(_lastPrintedX, _lastPrintedY);
                Console.ResetColor();
                Console.Write("0");
            }
            Console.SetCursorPosition(_x, _y);

            Console.ForegroundColor = _color;
            Console.Write("#");
            _lastPrintedX = _x;
            _lastPrintedY = _y;
            _hasBeenPrinted = true;
            
            
        }
        public Robot(int x, int y, ConsoleColor color)
        {
            _x = Math.Max(0, 69);
            _y = Math.Max(0, 24);
            _x = x;
            _y = y;
            _color = color;
             
        }
        
        
        
        
    }
    
}
